//原文链接：https://blog.csdn.net/ITSOK_123/article/details/123751338
//穷举法
class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size();
        int maxW = 0;
        for(int i =0;i<n-1;i++){
            int hei;
            for(int j = i+1;j<n;j++){
                hei = min(height[i],height[j]);
                int pro = (j-i)*hei;
                maxW = max(maxW,pro);
            }
        }
        return maxW;
    }
};

//双向指针
class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size();
        int maxW = 0;
        int i=0,j=n-1;
        int pro = 0,h = 0;
        while(i<j){
            h = min(height[i],height[j]);
            pro = h*(j-i);
            maxW = max(maxW,pro);
            if(height[i]<height[j]){
              i++;
            }else{
                j--;
              }
        }   
        return maxW;
    }
};
